<template>
  <div>
    <el-dialog
      title="任务执行记录"
      width="80%"
      :visible="visible"
      show-close
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      destroy-on-close
      @close="onClose"
      @open="onOpen"
    >
      <div :class="$style.body">
        <el-form inline>
          <el-form-item label="执行时间">
            <el-date-picker
              v-model="formQuery.timeRange"
              type="datetimerange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button @click="onQuery" size="medium" type="primary">查询</el-button>
          </el-form-item>
          <el-form-item>
            <el-button @click="onReset" size="medium">重置</el-button>
          </el-form-item>
        </el-form>
        <el-table :data="data" border v-loading="loading">
          <el-table-column width="108px" property="period" label="调价时段" align="center"></el-table-column>
          <el-table-column width="124px" property="channelCode" label="渠道编码" align="center"></el-table-column>
          <el-table-column property="execStartTime" label="开始时间" width="180" align="center">
            <template slot-scope="scope">
              {{ formatTime(scope.row.execStartTime) }}
            </template>
          </el-table-column>
          <el-table-column property="execEndTime" label="完成时间" width="180" align="center">
            <template slot-scope="scope">
              {{ formatTime(scope.row.execEndTime) }}
            </template>
          </el-table-column>
          <el-table-column property="successNum" label="成功" align="center"></el-table-column>
          <el-table-column property="failureNum" label="失败" align="center"></el-table-column>
          <el-table-column property="status" label="状态" align="center">
            <template slot-scope="scope">
              {{ formatModalStatus(scope.row.status) }}
            </template>
          </el-table-column>
          <el-table-column property="operate" label="操作" align="center">
            <template slot-scope="scope">
              <el-button @click="onDownErrorFile(scope.row)" v-if="scope.row.failureNum > 0" type="text">下载错误文件</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          :class="$style.tablePagination"
          @size-change="onPageSizeChange"
          @current-change="onPageNumChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 40, 50, 100]"
          :page-size="pageSize"
          layout="sizes, prev, pager, next, jumper, total"
          :total="total"
          :hide-on-single-page="false"
        >
        </el-pagination>
      </div>
      <span slot="footer">
        <div style="text-align:center;">
          <el-button type="success" @click="onOK">关 闭</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import Index from './index';
export default Index;
</script>

<style lang="scss" module>
@import './index.module.scss';
</style>
